<?php
if (isset($_GET["codigo"]))
{
	$cod = $_GET["codigo"];
				
	$result = cons_questoes($cod);

	echo $result;
}

function makeSqlConnection()
{
$DB_HostName = "localhost";
$DB_Name = "ios";
$DB_User = "root";
$DB_Pass = "root";

	$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error()); 

	mysql_select_db($DB_Name,$con) or die(mysql_error()); 

	return $con;
}

function disconnectSqlConnection($con)
{
	mysql_close($con);
}

function cons_questoes($cod)
{
	$con = makeSqlConnection();
	
	$sql = "SELECT descricao FROM tb_questoes where diario = $cod";

	$res = mysql_query($sql,$con) or die(mysql_error());
	
	$ret = mysql_num_rows($res).";";

	while ($row = mysql_fetch_array($res, MYSQL_NUM)) 
	{
		$ret .= $row[0];
		$ret .= ";";
	}

	mysql_free_result($res);
	
	disconnectSqlConnection($con);
	
	return $ret;
}// end of Function 

?>